$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'

#3 stellige prädikatsfunktion, die prüft, ob ein wert val in einem intervall von
#lower bis upper liegt
#within ::= (val, lower, upper) :: INT x INT x INT => Bool where lower <= val <= upper::
#test ( (2,1,3) => true, (-2,-3,-1) => true, (0,-1,1) => true, (1,1,2) => true,
#(2,1,2) =>  true, (1,2,4) => false, (-4,-3,-1) => false, (-2,-1,1) => false,
#(4,1,3) => false, ("a",2,3) => Err, (2,"a",3) => Err, (2,1,"a") => Err,
#(2.0,2,3) => Err, (2,2.0,3) => Err, (2,2,3.0) => Err, (1,2,1) => Err,
#(2,2,2) => Err)

def within?(val, lower, upper)
  check_pre((
    val.int? and
    lower.int? and
    upper.int? and
    (lower < upper)
    ))
  
  
    (((lower <= val) and (val <= upper)) ? true : false)
end